Link to local file for permalinks in webview#8583
Link to local file for permalinks in webview#8583Daniel-Aaron-Bloom wants to merge 10 commits intomicrosoft:mainfrom
Conversation
|
@microsoft-github-policy-service agree |
|
Yup. Much cleaner and more efficient. I've also added diff link support to open the diff view. |
alexr00
left a comment
There was a problem hiding this comment.
This is heading in a good direction! A few more comments:
src/common/utils.ts
Outdated
|
|
||
| // Process blob permalinks (exclude already processed links) | ||
| const blobPattern = new RegExp( | ||
| `<a\\s+(?![^>]*data-permalink-processed)([^>]*?href="https?:\/\/${escapedAuthority}\/${escapedRepoOwner}\/${escapedRepoName}\/blob\/[0-9a-f]{40}\/(?<filePath>[^"#]+)#L(?<startLine>\\d+)(?:-L(?<endLine>\\d+))?"[^>]*?)>(?<linkText>[^<]*?)<\/a>`, |
There was a problem hiding this comment.
Should a link like this work (I know it's a private repo, but the structure of the link): https://github.com/alexr00/playground/blob/f86be02708e48ed4648b224771995c7573213946/readme.md?#L6
I'm not seeing it get replaced for a PR in that repo.
There was a problem hiding this comment.
It should work, I'm using it in private repos right now (and it's being very helpful). It only doesn't replace the permalinks if the file doesn't exist locally (so you have to check out a PR branch before opening the view) and diff links if the files isn't present in the diff.
These two should show up in this repo, although at the time I made this comment the latter did not because of the different repoOwner (it has since been updated and now both appear to work):

This pull request adds the functionality to link to a file within the project in a comment on the PR/issue overview pages. This feature creates parity with #5558, so links appear and function identically in both locations. It also enables users to quickly jump around using a list of referenced file locations in the PR description or a comment.
Fixes #8571
This PR also adds a few
await this._waitForReady;in_replyMessageand_throwError, which I think are the correct behavior, and also without them this extension sometimes fails to respond.